package team;


import java.sql.*;
import java.util.ArrayList;

/**
 * To create a connection to oracle
 * @author jerry wu, Sean Peng, Qiwen Wu
 *
 */
public class DBOperation {
	private final String DB_DRIVER = "oracle.jdbc.driver.OracleDriver";
//	private final String DB_URL = "jdbc:oracle:thin:@localhost:1521:oracle";
//	private final String DB_URL = "jdbc:oracle:thin:@localhost:1521:mops";
	private final String DB_URL = "jdbc:oracle:thin:@localhost:1521:scott";
	private final String DB_USER = "system";
//	private final String DB_PASS = "Password1";
	private final String DB_PASS = "tiger";
	private static Connection con;
	private static Statement stmnt;
	
	/**
	 * Constructs a connection to oracle
	 */
	public DBOperation() {
		try {
			Class.forName(DB_DRIVER);
			con = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
			stmnt = con.createStatement();
			System.out.println("Connected to DB!");
			} catch (SQLException ex) {
			    System.out.println("Error "+ex);
			System.err.println(ex.getMessage());
			} catch (ClassNotFoundException ex) {
			System.err.println(ex.getMessage());
			}
	}
	
	/**
	 * Disconnect from DB
	 */
	public void disconnectFromDB() {
		try {
			stmnt.close();
			con.close();
			System.out.println("Disconnected from DB!");
		} catch (SQLException e) {
			System.err.println(e.getMessage());
		}
	}
	
	/**
	 * Query the table for Auto Maker from Oracle DB
	 * @return A Maker Set
	 */
	public ResultSet queryMaker() throws SQLException {
		
		 	String queryMaker = "SELECT Maker FROM AUTO"; 
			//String queryMaker = "SELECT table_name FROM all_tables WHERE table_name LIKE 'APL___'";
			ResultSet result = stmnt.executeQuery(queryMaker);
			System.out.println(queryMaker);
			return result;
	}
	
	public ResultSet queryMakerName(String aplValue) throws SQLException{
		String queryMaker = "SELECT MAKER FROM AUTO WHERE SHORTMAKER='" + aplValue + "'";
		ResultSet result = stmnt.executeQuery(queryMaker);
		return result;
	}
	
	/**
	 * Query Auto Maker info from Auto Table, the information will be stored into a HashMap in Result.java
	 * @return Binding relationship for AutoMaker full name and table name
	 * @throws SQLException
	 */
	public ResultSet createMakerTable() throws SQLException{
		String queryMaker = "SELECT * FROM AUTO";
		System.out.println("!!!"+queryMaker);
		ResultSet rs = stmnt.executeQuery(queryMaker);
		return rs;
	}
	
	/**
	 * Query car model by auto maker
	 * @return a model set
	 */
	public ResultSet queryModel(String maker) throws SQLException {
		String model = "SELECT model FROM " + maker;
		ResultSet rs = stmnt.executeQuery(model);
		return rs;
	}
	
	/**
	 * Query car year by maker, model from corresponding car maker table
	 * @return a year set
	 */
	public ResultSet queryYear(String maker, String model) throws SQLException {
		String year = "SELECT YEAR FROM " + maker + " WHERE MODEL = '" + model + "'";
		ResultSet rs = stmnt.executeQuery(year);
		return rs;
	}
	
	/**
	 * Query engine_type by maker, model, year
	 * @return a engine_type set
	 */
	public ResultSet queryEngineType(String maker, String model, String year) throws SQLException {
		String engine_type = "SELECT ENGINE_TYPE FROM " + maker 
							+ " WHERE MODEL = '" + model + "'"
							+ " AND YEAR = '" + year + "'";
		ResultSet rs = stmnt.executeQuery(engine_type);
		return rs;
	}
	
	/**
	 * Query description by maker, model, year from corresponding car maker table
	 * @return a description set
	 */
	public ResultSet queryDescription(String maker, String model, String year) throws SQLException {
		//make the statament type to be scrollable
		stmnt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
		
		String desc = "SELECT DESCRIPTION, LITRES, ENGINE_TYPE, CUBIC_INCHES, RLINK FROM " + maker 
				+ " WHERE MODEL = '" + model + "'"
				+ " AND YEAR = '" + year + "'";
		ResultSet rs = stmnt.executeQuery(desc);
		return rs;
	}
	
	/**
	 * Execute the sql for update auto frame - update auto maker not implemented
	 * @param updatedInfo the updated auto info
	 * @param originalInfo the original auto info
	 * @return updated result set - null if not updated
	 * @throws SQLException
	 */
	public ResultSet queryUpdateAuto(String[] updatedInfo, String[] originalInfo) throws SQLException {
		stmnt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
		
		ResultSet rs = null;
		if (updatedInfo[0].equals(originalInfo[0])) {
			String updateSQL = "UPDATE " + originalInfo[0] + " "
								+ "SET MODEL='"+updatedInfo[1]+"', YEAR='"+updatedInfo[2]+"', "
								+ "DESCRIPTION='"+updatedInfo[3]+"', LITRES='"+updatedInfo[4]+"', "
								+ "ENGINE_TYPE='"+updatedInfo[5]+"', CUBIC_INCHES='"+updatedInfo[6]+"' "
								+ "WHERE MODEL='"+originalInfo[1]+"'AND YEAR='"+originalInfo[2]+"' AND "
								+ "DESCRIPTION='"+originalInfo[3]+"' AND LITRES='"+originalInfo[4]+"' AND "
								+ "ENGINE_TYPE='"+originalInfo[5]+"' AND CUBIC_INCHES='"+originalInfo[6]+"'";
			rs = stmnt.executeQuery(updateSQL);
		} else {
			//Delete the tuple from old table
			String delOriginal = "DELETE FROM " + originalInfo[0] + " "
									+ "WHERE MODEL='"+originalInfo[1]+"'AND YEAR='"+originalInfo[2]+"' AND "
									+ "DESCRIPTION='"+originalInfo[3]+"' AND LITRES='"+originalInfo[4]+"' AND "
									+ "ENGINE_TYPE='"+originalInfo[5]+"' AND CUBIC_INCHES='"+originalInfo[6]+"'";
			stmnt.executeQuery(delOriginal);
			
			//Add tuple to new table
			String addUpdated = "INSERT INTO "+updatedInfo[0]+" VALUES"
								+ "('"+updatedInfo[1]+"', '"+updatedInfo[2]+"', "
								+ "'"+updatedInfo[3]+"', '"+updatedInfo[4]+"', '"+updatedInfo[5]+"', "
								+ "'"+updatedInfo[6]+"', "+originalInfo[7]+")";
			stmnt.executeQuery(addUpdated);
		}
		return rs;
	}
	
	/**
	 * Create a new auto
	 * @param updatedInfo new auto info
	 * @throws SQLException
	 */
	public void createNewAuto(String[] updatedInfo) throws SQLException {
		String command = "INSERT INTO "+updatedInfo[0]+" VALUES"
				+ "('"+updatedInfo[1]+"', '"+updatedInfo[2]+"', "
				+ "'"+updatedInfo[3]+"', '"+updatedInfo[4]+"', '"+updatedInfo[5]+"', "
				+ "'"+updatedInfo[6]+"', "+updatedInfo[7]+")";
		
		stmnt.executeQuery(command);
	}
	
	/**
	 * Query table for vendor from Oracle DB
	 * @return set of vendor's name
	 * @throws SQLException
	 */
	public ResultSet queryVendor() throws SQLException {
		
		String queryVendor = "SELECT table_name FROM all_tables WHERE table_name LIKE 'RDIM___'";
		ResultSet result = stmnt.executeQuery(queryVendor);
		
		return result;
	}
		
	/**
	 * Query vendor's name by rLink from table RADCRX
	 * @param rLink number associate auto part and vendor
	 * @return set of vendor's name
	 * @throws SQLException
	 */
	public ResultSet queryVendor(Integer rLink) throws SQLException {
		
		String queryVendor = "SELECT ARS1, ARS2, ARS3, ARS4, MOD1, MOD2, MOD3, MOD4, BEH1, BEH2, BEH3, BEH4, DAN1, DAN2, DAN3, DAN4 " +
				"FROM RADCRX WHERE RLINK = " + rLink;
		ResultSet result = stmnt.executeQuery(queryVendor);
		
		return result;
	}
	
	/**
	 * Query part by vendor's name from corresponding vendor's table
	 * @param vendor vendor's name
	 * @return a part number set
	 * @throws SQLException
	 */
	public ResultSet queryPartNumber(String vendor) throws SQLException {
		
		String queryPartNumber = "SELECT P_NUMBER FROM " + vendor + " ORDER BY P_NUMBER";
		ResultSet rs = stmnt.executeQuery(queryPartNumber);
		
		return rs;
	}
	
	/**
	 * Qeury part by vendor's name and rLink from table RADCRX
	 * @param vendor
	 * @param rLink
	 * @return
	 * @throws SQLException
	 */
	public ResultSet queryPartNumber(String vendor, Integer rLink) throws SQLException {
		
		String v = "";
		
		if(vendor.equalsIgnoreCase("RDIMARS"))
			v = "ARS1, ARS2, ARS3, ARS4";
		else if(vendor.equalsIgnoreCase("RDIMBEH"))
			v = "BEH1, BEH2, BEH3, BEH4";
		else if(vendor.equalsIgnoreCase("RDIMDAN"))
			v = "DAN1, DAN2, DAN3, DAN4";
		else
			v = "MOD1, MOD2, MOD3, MOD4";
		
		String queryPartNumber = "SELECT " + vendor + " FROM RADCRX WHERE RLINK = " + rLink;
		ResultSet rs = stmnt.executeQuery(queryPartNumber);
		
		return rs;
	}
	
	/**
	 * Query part specification by vendor's name, part number from from corresponding vendor's table
	 * @param vendor vendor's name
	 * @param partNumber part number
	 * @return a part specification set
	 * @throws SQLException
	 */
	public ResultSet queryPartSpec(String vendor, String partNumber) throws SQLException {
		
		String queryPartSpec = "SELECT * FROM " + vendor + " WHERE P_NUMBER = '" + partNumber + "'";
		ResultSet rs = stmnt.executeQuery(queryPartSpec);
		
		return rs;
	}
	
	/**
	 * Get the column name from the specific table
	 * @param tableName the name for the table
	 * @return a result set for the queried column name
	 * @throws SQLException
	 */
	public ResultSet queryColumnName(String tableName) throws SQLException {
		
		String tName = tableName.toUpperCase();
		String queryColumnName = "SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = '" + tName + "'";
		ResultSet rs = stmnt.executeQuery(queryColumnName);
		
		return rs;
	}
	
	/**
	 * Insert new part into the database
	 * @param vendor vendor's name
	 * @param data the part data from user's input
	 * @throws SQLException
	 */
	public void insertNewPart(String vendor, ArrayList<String> data) throws SQLException {
		
		StringBuilder sb = new StringBuilder();
		
		sb.append("INSERT INTO " + vendor + " VALUES (");
		
		for(int i=0; i<data.size(); i++) {
			if(i+1 < data.size())
				sb.append("'" + data.get(i) + "', ");
			else
				sb.append("'" + data.get(i) + "'");
		}
		
		sb.append(")");
		
		stmnt.executeQuery(sb.toString());
	}
	
	/**
	 * Insert new part into the database
	 * @param vendor vendor's name
	 * @param data the part data from user's input
	 * @param rLink
	 * @throws SQLException
	 */
	public void insertNewPart(String vendor, ArrayList<String> data, Integer rLink) throws SQLException {
		
		StringBuilder sb = new StringBuilder();
		
		sb.append("INSERT INTO " + vendor + " VALUES (");
		
		for(int i=0; i<data.size(); i++) {
			if(i+1 < data.size())
				sb.append("'" + data.get(i) + "', ");
			else
				sb.append("'" + data.get(i) + "'");
		}
		
		sb.append(")");
		
		stmnt.executeQuery(sb.toString());
		
	}
	
	/**
	 * Check if the given part is existing in the database
	 * @param vendor vendor's name
	 * @param partNum part number
	 * @return
	 * @throws SQLException
	 */
	public ResultSet checkExisting(String vendor, String partNum) throws SQLException{
		
		String isExisting = "SELECT P_NUMBER from " + vendor + " WHERE EXISTS " +
				"(SELECT P_NUMBER from " + vendor + " WHERE P_NUMBER = '" + partNum + "')";
		
		ResultSet rs = stmnt.executeQuery(isExisting);
		
		return rs;
	}
	
	/**
	 * Delete part from database
	 * @param vendor vendor's name
	 * @param partNum part number
	 */
	public void deletePart(String vendor, String partNum) throws SQLException {
		
		String deletePart = "DELETE FROM " + vendor + " WHERE P_NUMBER = '" + partNum + "'";
		stmnt.executeQuery(deletePart);
	}
	
	/**
	 * Update the RADCRX table after a part is deleted
	 * @param vendor vendor's name
	 * @param partNum part number
	 * @throws SQLException
	 */
	public void updateRADCRX(String vendor, String partNum) throws SQLException {
		
		ArrayList<String> updateSQL = new ArrayList<String>();
		
		if(vendor.equalsIgnoreCase("RDIMARS")) {
			updateSQL.add("UPDATE RADCRX SET ARS1 = NULL WHERE ARS1 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS2 = NULL WHERE ARS2 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS3 = NULL WHERE ARS3 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS4 = NULL WHERE ARS4 = '" + partNum + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMBEH")) {
			updateSQL.add("UPDATE RADCRX SET BEH1 = NULL WHERE BEH1 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH2 = NULL WHERE BEH2 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH3 = NULL WHERE BEH3 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH4 = NULL WHERE BEH4 = '" + partNum + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMDAN")) {
			updateSQL.add("UPDATE RADCRX SET DAN1 = NULL WHERE DAN1 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN2 = NULL WHERE DAN2 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN3 = NULL WHERE DAN3 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN4 = NULL WHERE DAN4 = '" + partNum + "'");
		}
		else {
			updateSQL.add("UPDATE RADCRX SET MOD1 = NULL WHERE MOD1 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD2 = NULL WHERE MOD2 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD3 = NULL WHERE MOD3 = '" + partNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD4 = NULL WHERE MOD4 = '" + partNum + "'");
		}
		
		for(String s : updateSQL)
			stmnt.executeQuery(s);
	}
	
	/**
	 * Update RADCRX table after part number is modified
	 * @param vendor vendor's name
	 * @param newPartNum
	 * @param oldPartNum
	 * @throws SQLException
	 */
	public void updateRADCRX(String vendor, String newPartNum, String oldPartNum) throws SQLException {
		
		ArrayList<String> updateSQL = new ArrayList<String>();
		
		if(vendor.equalsIgnoreCase("RDIMARS")) {
			updateSQL.add("UPDATE RADCRX SET ARS1 = '" + newPartNum + "' WHERE ARS1 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS2 = '" + newPartNum + "' WHERE ARS2 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS3 = '" + newPartNum + "' WHERE ARS3 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET ARS4 = '" + newPartNum + "' WHERE ARS4 = '" + oldPartNum + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMBEH")) {
			updateSQL.add("UPDATE RADCRX SET BEH1 = '" + newPartNum + "' WHERE BEH1 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH2 = '" + newPartNum + "' WHERE BEH2 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH3 = '" + newPartNum + "' WHERE BEH3 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET BEH4 = '" + newPartNum + "' WHERE BEH4 = '" + oldPartNum + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMDAN")) {
			updateSQL.add("UPDATE RADCRX SET DAN1 = '" + newPartNum + "' WHERE DAN1 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN2 = '" + newPartNum + "' WHERE DAN2 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN3 = '" + newPartNum + "' WHERE DAN3 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET DAN4 = '" + newPartNum + "' WHERE DAN4 = '" + oldPartNum + "'");
		}
		else {
			updateSQL.add("UPDATE RADCRX SET MOD1 = '" + newPartNum + "' WHERE MOD1 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD2 = '" + newPartNum + "' WHERE MOD2 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD3 = '" + newPartNum + "' WHERE MOD3 = '" + oldPartNum + "'");
			updateSQL.add("UPDATE RADCRX SET MOD4 = '" + newPartNum + "' WHERE MOD4 = '" + oldPartNum + "'");
		}
		
		for(String s : updateSQL) {
			
			//System.out.println(s);
			stmnt.executeQuery(s);
		}
	}
	
	/**
	 * Update the RADCRX table after a part is assigned to the new auto
	 * @param vendor vendor's name
	 * @param partNum part number
	 * @param rLink
	 * @throws SQLException
	 */
	public void updateRADCRX(String vendor, String partNum, Integer rLink) throws SQLException {
		
		ArrayList<String> updateSQL = new ArrayList<String>();
		
		if(vendor.equalsIgnoreCase("RDIMARS")) {
			updateSQL.add("UPDATE RADCRX SET ARS1 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET ARS2 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET ARS3 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET ARS4 = " + partNum + " WHERE RLINK = '" + rLink + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMBEH")) {
			updateSQL.add("UPDATE RADCRX SET BEH1 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET BEH2 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET BEH3 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET BEH4 = " + partNum + " WHERE RLINK = '" + rLink + "'");
		}
		else if(vendor.equalsIgnoreCase("RDIMDAN")) {
			updateSQL.add("UPDATE RADCRX SET DAN1 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET DAN2 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET DAN3 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET DAN4 = " + partNum + " WHERE RLINK = '" + rLink + "'");
		}
		else {
			updateSQL.add("UPDATE RADCRX SET MOD1 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET MOD2 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET MOD3 = " + partNum + " WHERE RLINK = '" + rLink + "'");
			updateSQL.add("UPDATE RADCRX SET MOD4 = " + partNum + " WHERE RLINK = '" + rLink + "'");
		}
		
		for(String s : updateSQL) {
			stmnt.executeQuery(s);
		}
	}
	
	/**
	 * Update part information
	 * @param vendor vendor's name
	 * @param partNum part number
	 * @param inputData part information from user's input
	 * @throws SQLException
	 */
	public void updatePart(String vendor, String partNum, ArrayList<String> inputData) throws SQLException{
		
		String updatePart = "UPDATE " + vendor + " SET " +
							"P_NUMBER = '" + inputData.get(0) + "', " +
							"CORE = '" + inputData.get(1) + "', " +
							"INHEAD = '" + inputData.get(2) + "', " +
							"OUTHEAD = '" + inputData.get(3) + "', " +
							"INCON = '" + inputData.get(4) + "', " +
							"OUCON = '" + inputData.get(5) + "', " +
							"TMOUNT = '" + inputData.get(6) + "', " +
							"OILCOOL = '" + inputData.get(7) + "', " +
							"PRICE = '" + inputData.get(8) + "', " +
							"AMOUNT = '" + inputData.get(9) + "' " +
							"WHERE P_NUMBER = '" + inputData.get(0) + "'";
		stmnt.executeQuery(updatePart);
	}
	
	/**
	 * Create a new Auto Maker Table
	 * @param maker table name
	 * @return Not Null ResultSet if create successfully
	 * @throws SQLException
	 */
	public void createMaker(String maker) throws SQLException {
		String createMaker = "CREATE TABLE " + maker + 
				"(MODEL      VARCHAR2(25)    NOT NULL," +
				"YEAR       VARCHAR2(4) NOT NULL," +
				"DESCRIPTION    VARCHAR2(51)," +
				"LITRES     VARCHAR2(4)," +
				"ENGINE_TYPE    VARCHAR2(3)," +
				"CUBIC_INCHES   VARCHAR2(6)," +
				"RLINK      NUMBER(4)," +
				"PRIMARY KEY    (MODEL, YEAR, DESCRIPTION, LITRES, ENGINE_TYPE, CUBIC_INCHES, RLINK)," +
				"FOREIGN KEY    (RLINK) REFERENCES RADCRX)";
		stmnt.executeQuery(createMaker);
	}
	
	/**
	 * Add the Binding of Auto Maker Full Name and Auto Maker Table Name into Auto Table
	 * @param makerName 
	 * @param tableName
	 * @throws SQLException
	 */
	public void addMakerToAutoTable(String makerName, String tableName) throws SQLException{
		this.createMaker(tableName);
		String add = "INSERT INTO AUTO VALUES('"+makerName+"', '"+tableName+"')";
		stmnt.executeQuery(add);
	}
	
	/**
	 * Get the Maximum Value of RLink, for creating a new rLink
	 * @return ResultSet Contains the Max of rLink
	 * @throws SQLException
	 */
	public ResultSet getMaxRLink() throws SQLException {
		String command = "SELECT COUNT(*) FROM RADCRX";
		return stmnt.executeQuery(command);
	}
	
	/**
	 * Add an new rLink to RADCRX
	 * @param rLink new rLink to add
	 * @throws SQLException
	 */
	public void addNewRLink(String rLink) throws SQLException {
		String command = "INSERT INTO RADCRX VALUES('"+rLink+"', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')";
		stmnt.executeQuery(command);
	}
	
	public void deleteAuto(String deleteQuery) throws SQLException
	{
		stmnt.execute(deleteQuery);
	}
}
